#ifndef PAINT_H
#define PAINT_H

#include <QObject>
#include <QChartView>
#include <QLineSeries>
#include <QSplineSeries>
#include <QTimer>
#include "struct.h"
#include <QValueAxis>
#include <QtCharts>
QT_CHARTS_USE_NAMESPACE

//typedef struct para {
//    int temp;
//    int hum;
//    int ligh;

class paint : public QChartView
{
    Q_OBJECT
public:
    explicit paint(QChartView *parent = nullptr);
    ~paint();

    float fPointX;      // X轴坐标点
    float fPointX_month;  //月份X轴的坐标
    float fPointX_week;   //月份X轴的坐标
    QChart *chart, *chart_month,*chart_week;
    QLineSeries *series0,*series1,*series2;//series0 温度，series1 湿度 series2 光照----画当天的。
    QSplineSeries *series0_month,*series1_month,*series2_month;
    QSplineSeries *series0_week,*series1_week,*series2_week;
    QValueAxis *axisY_day,*axisY_lux_day,*axisX_day;
    QValueAxis *axisY_week,*axisY_lux_week,*axisX_week;
    QValueAxis *axisY_month,*axisY_lux_month,*axisX_month;
    QTimer timer;  //定时器

    void get_x_data();//获取x轴值
    void get_y_data(env_data1 data);//获取y轴值
    void get_y_data_week(QVector<env_data1> data);     //Y轴值-week-每天一个平均值总计7个
    void get_y_data_month(QVector<env_data1> data);    //Y轴值-month-每天一个天平均值总计30个。
    void paint_x_axes();//绘制x坐标
    void paint_y_axes();//绘制y坐标

    void paint_month_pic();//绘制整个月的图
    void paint_week_pic(); //绘制整个周的图

    void paint_month_x_axes();//绘制当月x坐标
    void paint_month_y_axes();//绘制当月y坐标

    void paint_week_x_axes();//绘制当周x坐标
    void paint_week_y_axes();//绘制当周y坐标

    void paint_y_lux_day_axes();
    void paint_y_lux_week_axes();
    void paint_y_lux_month_axes();

signals:
    void to_paint_signal();
    void set_chartView_signal();
    void set_chartView_2_signal();
    void set_chartView_3_signal();
public slots:
    void get_asix_slot();
    void paint_picture_slot();
private:
    env_data1 para;      //存温湿度，光照度信息。

    QValueAxis *axisY;  //Y轴
    QValueAxis *axisX;  //X轴
};

#endif // PAINT_H
